home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / adg_7_8.zip / SETUPDLG.C < prev    next >
C/C++ Source or Header  |  1991-02-21  |  5KB  |  163 lines

  1. /****************************************************************************
  2. Module name: SetupDlg.C
  3. Programmer : Jeffrey M. Richter.
  4. *****************************************************************************/
  5.  
  6. #include "..\nowindws.h"
  7. #undef NOCTLMGR
  8. #undef NOKERNEL
  9. #undef NOLSTRING
  10. #undef NOMB
  11. #undef NOOPENFILE
  12. #undef NOSYSMETRICS
  13. #undef NOUSER
  14. #undef NOWINMESSAGES
  15. #include <windows.h>
  16.  
  17. #include "..\Meter.04\Meter.H"
  18. #include "Setup.h"
  19. #include "SetupInf.h"
  20.  
  21. // Setup's initial sign on screen.  Asks user for destination directory.
  22. BOOL FAR PASCAL WelcomeDlgProc (HWND hDlg, WORD wMsg, WORD wParam, LONG lParam) {
  23.    BOOL fProcessed = TRUE;
  24.    char szBuf[MAXDIR];
  25.    OFSTRUCT ofStruct;
  26.    RECT rc;
  27.  
  28.    switch (wMsg) {
  29.       case WM_INITDIALOG:
  30.          SetupInfoSys(SIM_GETAPPNAME, 0, szBuf);
  31.          SetWindowText(hDlg, szBuf);
  32.          GetWindowRect(hDlg, &rc);
  33.          SetWindowPos(hDlg, NULL,
  34.             (GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2,
  35.             (GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 3,
  36.             0, 0, SWP_NOSIZE | SWP_NOZORDER);
  37.  
  38.          SetupInfoSys(SIM_GETDEFDIR, 0, szBuf);
  39.          SetDlgItemText(hDlg, ID_DESTPATH, szBuf);
  40.          break;
  41.  
  42.       case WM_COMMAND:
  43.          switch (wParam) {
  44.             case ID_DESTPATH:
  45.                EnableWindow(GetDlgItem(hDlg, IDOK),
  46.                   (BOOL) SendMessage(LOWORD(lParam), EM_LINELENGTH, 0, 0));
  47.                break;
  48.  
  49.             case IDOK:
  50.                GetDlgItemText(hDlg, ID_DESTPATH, szBuf, sizeof(szBuf));
  51.                OpenFile(szBuf, &ofStruct, OF_PARSE);
  52.                lstrcpy(_szDstDir, (LPSTR) ofStruct.szPathName);
  53.                // Do IDCANCEL case
  54.  
  55.             case IDCANCEL:
  56.                EndDialog(hDlg, wParam);
  57.                break;
  58.          }
  59.          break;
  60.  
  61.       default:
  62.          fProcessed = FALSE;
  63.          break;
  64.    }
  65.    return(fProcessed);
  66. }
  67.  
  68.  
  69. // Displays copying status.  Allows user to cancel the installation.
  70. BOOL FAR PASCAL StatusDlgProc (HWND hDlg, WORD wMsg, WORD wParam, LONG lParam) {
  71.    BOOL fProcessed = TRUE; int nResult; char szBuf[100];
  72.    RECT rc;
  73.  
  74.    switch (wMsg) {
  75.       case WM_INITDIALOG:
  76.          SetupInfoSys(SIM_GETAPPNAME, 0, szBuf);
  77.          SetWindowText(hDlg, szBuf);
  78.          GetWindowRect(hDlg, &rc);
  79.          SetWindowPos(hDlg, NULL,
  80.             (GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2,
  81.             (GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 3,
  82.             0, 0, SWP_NOSIZE | SWP_NOZORDER);
  83.          break;
  84.  
  85.       case WM_SHOWWINDOW:
  86.          fProcessed = FALSE;
  87.          if (!wParam) break;
  88.          EnableWindow(GetDlgItem(hDlg, IDCANCEL), TRUE);
  89.          SetDlgItemText(hDlg, ID_STATLINE1, "");
  90.          SetDlgItemText(hDlg, ID_STATLINE2, "");
  91.          SendDlgItemMessage(hDlg, ID_METER, MM_SETPARTSCOMPLETE, 0, 0);
  92.          SendDlgItemMessage(hDlg, ID_METER, MM_SETPARTSINJOB, 0, 0);
  93.          break;
  94.  
  95.       case WM_COMMAND:
  96.          switch (wParam) {
  97.             case IDOK:
  98.                // User presses ENTER.  DO IDCANCEL case.
  99.             case IDCANCEL:
  100.                nResult = MsgBox(_hInstance, hDlg, IDS_QUERYABORT, _szAppName,
  101.                   MB_ICONQUESTION | MB_YESNO);
  102.                if (nResult == IDYES)
  103.                   EnableWindow(GetDlgItem(hDlg, IDCANCEL), FALSE);
  104.                break;
  105.          }
  106.          break;
  107.  
  108.       default:
  109.          fProcessed = FALSE;
  110.          break;
  111.    }
  112.    return(fProcessed);
  113. }
  114.  
  115. // Prompt's user to insert a different diskette.
  116. BOOL FAR PASCAL InsertDiskDlgProc (HWND hDlg, WORD wMsg, WORD wParam, LONG lParam) {
  117.    BOOL fProcessed = TRUE;
  118.    char szBuf[100];
  119.    RECT rc;
  120.  
  121.    switch (wMsg) {
  122.       case WM_INITDIALOG:
  123.          // lParam is address of diskette description.
  124.          SetupInfoSys(SIM_GETAPPNAME, 0, szBuf);
  125.          SetWindowText(hDlg, szBuf);
  126.          GetWindowRect(hDlg, &rc);
  127.          SetWindowPos(hDlg, NULL,
  128.             (GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2,
  129.             (GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 3,
  130.             0, 0, SWP_NOSIZE | SWP_NOZORDER);
  131.  
  132.          // Throw away the data segment and use the new one.
  133.          // This is in case the data segment has moved.
  134.          SetDlgItemText(hDlg, ID_DISKNAME, (LPSTR) (char NEAR *) lParam);
  135.          SetDlgItemText(hDlg, ID_SRCPATH, _szSrcDir);
  136.          SendDlgItemMessage(hDlg, ID_SRCPATH, EM_LIMITTEXT, sizeof(_szSrcDir), 0);
  137.          MessageBeep(0);
  138.          break;
  139.  
  140.       case WM_COMMAND:
  141.          switch (wParam) {
  142.             case ID_SRCPATH:
  143.                EnableWindow(GetDlgItem(hDlg, IDOK),
  144.                   (BOOL) SendMessage(LOWORD(lParam), EM_LINELENGTH, 0, 0));
  145.                break;
  146.  
  147.             case IDOK:
  148.                GetDlgItemText(hDlg, ID_SRCPATH, _szSrcDir, sizeof(_szSrcDir));
  149.                // Do IDCANCEL case
  150.  
  151.             case IDCANCEL:
  152.                EndDialog(hDlg, wParam);
  153.                break;
  154.          }
  155.          break;
  156.  
  157.       default:
  158.          fProcessed = FALSE;
  159.          break;
  160.    }
  161.    return(fProcessed);
  162. }
  163.